package com.acme.bankapp.domain.accounts;

import com.acme.bankapp.exceptions.NegativeAmountException;
import com.acme.bankapp.exceptions.NotEnoughFundsException;

/**
 * 
 * Holds balance info.
 * Ensures safety of business rules.
 *
 */
public abstract class AbstractAccount implements Account{
	protected AccountType accountType;
	protected double balance;

	/**
	 * Withdraws amount > 0. from account.
	 * @param amount to be withdrawn.
	 * @return true if amount is non-negative and amount is small enough to be withdrawn, false otherwise.
	 */
	public abstract boolean withdraw(double amount) throws NotEnoughFundsException, NegativeAmountException;

	/**
	 * Adds amount > 0. to account's balance.
	 * @param amount to be deposited.
	 * @return true if amount non-negative, false otherwise.
	 */
	public abstract boolean deposit(double amount) throws NegativeAmountException;

	/**
	 * Returns current balance (may be negative)
	 * @return current balance.
	 */
	public double getBalance() {
		return balance;
	}

	/**
	 * Returns type of account: Savings or Checking.
	 * @return Type of account.
	 */
	public AccountType getAccountType(){
		return accountType;
	};
}
